//获取应用实例
const app = getApp()
Page({
  data: {
    pwdone: '',
    pwdtwo: '',
    // 组件所需的参数
    nvabarData: {
      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
      title: '设置支付密码', //导航栏 中间的标题
    },
    // 此页面 页面内容距最顶部的距离
    height: app.globalData.height * 2 + 20,
  },
  onLoad() {
    console.log(this.data.height)
  },
  pwdone: function (e) {
    this.setData({
      pwdone: e.detail.value
    })
  },
  pwdtwo: function (e) {
    this.setData({
      pwdtwo: e.detail.value
    })
  },
  submitpwd: function () {
    let pwdone = this.data.pwdone;
    let pwdtwo = this.data.pwdtwo;
    if (pwdone == pwdtwo == null) {
      wx.showToast({
        title: '密码为空',
        icon: 'fail',
        duration: 2000,
        success: function () {

        }
      })
    } else if (pwdone !== pwdtwo) {
      wx.showToast({
        title: '密码不一致',
        icon: 'fail',
        duration: 2000,
        success: function () {

        }
      })
    } else if (pwdone == pwdtwo) {
      let pwdone = this.data.pwdone;
      wx.showToast({
        title: '修改成功',
        icon: 'fail',
        duration: 2000,
        success: function () {
          let url = app.globalData.URL + 'system/user/wx/set/payPassword?password=' + pwdone;
          let data = {};
          app.wxRequest('PUT', url, data, (res) => {
            console.log(res)
            wx.navigateBack({
              delta:1
            })
          }, (err) => {
            console.log(err.errMsg)
          })
        }
      })
    }
  }

})